/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.paymentdetail
 * PaymentdetailController.java
 * 创建人:小胡
 * 时间：2017年01月24日 10:09:14
 *
 */
package com.tz.web.paymentdetail;

import com.tz.auth.AuthPassport;
import com.tz.bean.Paymentdetail;
import com.tz.bean.TzParams;
import com.tz.service.paymentdetail.IPaymentdetailService;
import com.tz.util.TmStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * 虚拟账户明细web
 * PaymentdetailController
 * 创建人:小胡
 * 时间：2017年01月24日 10:09:14
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/wallet/paymentdetail")
public class PaymentdetailController {
	
	@Autowired
	private IPaymentdetailService paymentdetailService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params,Model model){
		if(TmStringUtils.isNotEmpty(params.getKeyword())){
			model.addAttribute("keywords" ,params.getKeyword());
		}
		return "wallet/paymentdetail/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		model.addAttribute("datas", paymentdetailService.findPaymentdetails(params));
		model.addAttribute("itemCount", paymentdetailService.count(params));
		return "wallet/paymentdetail/template";
	}

	@ResponseBody
	@RequestMapping(value="/update",method= RequestMethod.POST)
	public String update(Paymentdetail paymentdetail){
		paymentdetailService.update(paymentdetail);
		return "success";
	}


	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		paymentdetailService.delete(params);
		return "success";
	}
	@RequestMapping("/add")
    public String add(TzParams params){
		return "wallet/paymentdetail/add";
   }


	@RequestMapping(value = "/edit/{id}" ,method = RequestMethod.GET)
    public String edit(@PathVariable("id") Integer id , Model model){
		HashMap<String ,Object> paymentdetail = paymentdetailService.getPaymentdetail(id);
		model.addAttribute("paymentdetail",paymentdetail);
		return "wallet/paymentdetail/edit";
	}
}
